package cn.ustb.controller;

import cn.ustb.entity.TeacherInformation;
import cn.ustb.entity.User;
import cn.ustb.service.TeacherInformationService;
import cn.ustb.serviceImpl.TeacherInformationServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;

/**
 * @author yuyan
 */
@WebServlet("/teacherInformationServlet.do")
public class TeacherInformationServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //获得教师信息，转换到显示页面显示教师信息
        HttpSession session = request.getSession();
        User user = (User) session.getAttribute("user");
        TeacherInformationService teacherInformationService=new TeacherInformationServiceImpl();
        TeacherInformation teacherInformation=teacherInformationService.get(user);
        request.setAttribute("teacherInformation", teacherInformation);
        request.getRequestDispatcher("/teacherinformation.jsp").forward(request, response);
    }
}
